<template>
	<view class="personal-info-page">
		<view class="up-view">
			<view class="custom-navbar">
<!-- 				<view class="nav-left" @click="goBack">
					<global-arrow direction="left" :size="29" color="#fff"></global-arrow>
				</view>
				<view class="nav-title">
					<text>个人信息</text>
				</view>
				<view class="nav-right">
				</view> -->
			</view>
		</view>

		<!-- 信息列表 -->
		<view class="info-list">
			<view class="cardUp">
				<!-- 头像项 -->
				<view class="info-item" @click="goChooseAvatar">
					<text class="item-label">头像</text>
					<view class="item-content">
						<image class="avatar" :src="userInfo.avatar" mode="aspectFill"></image>
						<global-arrow direction="right" :size="22" color="#a3a3a3"></global-arrow>
					</view>
				</view>
				
				<!-- 姓名项 -->
				<view class="info-item" ><!-- //@click="editName" -->
					<text class="item-label">姓名</text>
					<text class="item-value">{{ userInfo.name }}</text>
				</view>
				
				<!-- 电话项 -->
				<view class="info-item" @click="goUpdatePhone">
					<text class="item-label">电话</text>
					<view class="item-content">
						<text class="item-value">{{ userInfo.phone }}</text>
						<global-arrow direction="right" :size="22" color="#a3a3a3"></global-arrow>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>
<script>
	export default {
		data() {
			return {
				userInfo: {
					avatar: '/static/images/头3.jpg', // 实际可能是网络URL
					name: '王先生',
					phone: '18602564789'
				}
			};
		},
		methods: {
			goBack() {
				uni.navigateBack();
			},
			goChooseAvatar(){
				uni.navigateTo({
					url:"/my/pages/infoEdit_Avatar/infoEdit_Avatar"
				})
			},
			goUpdatePhone(){
				uni.navigateTo({
					url:"/my/pages/infoEdit_Phone/infoEdit_Phone"
				})
			},
			chooseAvatar() {
				// 选择头像逻辑，可调用uni.chooseImage等API
				uni.chooseImage({
					count: 1,
					sourceType: ['album', 'camera'],
					success: (res) => {
						const tempFilePath = res.tempFilePaths[0];
						this.userInfo.avatar = tempFilePath;
						// 这里还可将图片上传到服务器，保存永久地址
					}
				});
			},
			editName() {
				// 编辑姓名逻辑，可弹出输入框等
				uni.showModal({
					title: '编辑姓名',
					content: '请输入新姓名',
					inputPlaceholder: '请输入姓名',
					success: (res) => {
						if (res.confirm && res.inputValue) {
							this.userInfo.name = res.inputValue;
						}
					}
				});
			}
		}
	};
</script>

<style scoped>
	.page {
		padding: 0 10rpx;
		background-color: #F8F8F8;
	}

	.up-view {
		padding: 0 20rpx;
		/* background: linear-gradient(to bottom, #3788FF, #0963E7); */
		color: #fff;
		padding-bottom: 250rpx;
		/* 1. 基础渐变背景（作为底层） */
		background: linear-gradient(to bottom, #3788FF, #0963E7);

		/* 2. 添加背景图（叠加在渐变上） */
		/* background-image: url('/static/icons/组 8.png'); */
		/* 背景图路径 */

		/* 3. 背景图属性设置 */
		background-repeat: no-repeat;
		/* 不重复平铺 */
		background-size: cover;
		/* 覆盖整个容器（可能裁剪） */
		/* 可选：background-size: contain; 完整显示图片（可能留空白） */

		background-position: center center;
		/* 图片居中显示 */
		background-attachment: scroll;
		/* 随内容滚动（默认值） */

		/* 图片层（在渐变上方） */
		background-blend-mode: overlay;
		/* 混合模式（可选） */
	}

	.custom-navbar {
		display: flex;
		align-items: center;
		justify-content: space-between;
		height: 88rpx;
		padding: 0 10rpx;
		font-weight: 300;
		box-sizing: border-box;
	}

	.nav-title {
		margin-right: 17rpx;
	}

	.personal-info-page {
		background-color: #f5f5f5;
		height: 100vh;
	}


	.info-list {
		margin-top: 20rpx;
		border-radius: 100rpx;
		padding: 20rpx;
	}
	.cardUp{
		margin-top: -260rpx;
		border-radius: 20rpx;
		background-color: #fff;
		padding: 10rpx;
	}

	.info-item {
		display: flex;
		justify-content: space-between;
		align-items: center;
		border-bottom: 2rpx solid #F8F8F8;
		padding: 40rpx;
	}

	.item-label {
		font-size: 28rpx;
		color: #333;
	}

	.item-content {
		display: flex;
		align-items: center;
	}

	.avatar {
		width: 80rpx;
		height: 80rpx;
		border-radius: 50%;
		margin-right: 10rpx;
	}

	.item-value {
		font-size: 28rpx;
		color: #666;
		margin-right: 10rpx;
	}
</style>